import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PluginsVO, PluginsForm, PluginsQuery } from '@/api/goods/plugins/types';

/**
 * 查询插件列表
 * @param query
 * @returns {*}
 */

export const listPlugins = (query?: PluginsQuery): AxiosPromise<PluginsVO[]> => {
  return request({
    url: '/order/plugins/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询插件详细
 * @param id
 */
export const getPlugins = (id: string | number): AxiosPromise<PluginsVO> => {
  return request({
    url: '/order/plugins/' + id,
    method: 'get'
  });
};

/**
 * 新增插件
 * @param data
 */
export const addPlugins = (data: PluginsForm) => {
  return request({
    url: '/order/plugins',
    method: 'post',
    data: data
  });
};
/**
 * 分享插件
 * @param data
 */
export const sharePlugins = (ids) => {
  return request({
    url: '/order/plugins/' + ids,
    method: 'post'
  });
};

/**
 * 修改插件
 * @param data
 */
export const updatePlugins = (data: PluginsForm) => {
  return request({
    url: '/order/plugins',
    method: 'put',
    data: data
  });
};

/**
 * 删除插件
 * @param id
 */
export const delPlugins = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/plugins/' + id,
    method: 'delete'
  });
};
